﻿using System.Collections.Generic;
using NOSDC.Pocos;
using NOSDC.Repositories;
using NOSDC.Repositories.Comments;

namespace NOSDC.Services
{
    public class CommentService : ICommentService
    {
        private readonly ICommentRepository _repository;

        public CommentService()
        {
            _repository = new CommentRepository();
        }

        public void PostComment(Comment comment)
        {
            comment.Message = comment.Message.Replace("\n", "<br />");
           _repository.PostComment(comment);
        }

        public IList<Comment> GetCommentsByArticle(int articleID)
        {
            return _repository.GetCommentsByArticle(articleID);
        }


        public IList<Comment> GetCommentsByArticle(int articleID, int page, int pageSize)
        {
            return _repository.GetCommentsByArticle(articleID, page, pageSize);
        }

        public int TotalComments(int articleID)
        {
            return _repository.TotalComments(articleID);
        }
    }
}
